package com.itheima.tcp;

import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server {

    public static void main(String[] args) throws IOException {
        //创建服务端对象
        ServerSocket ss = new ServerSocket(8888);
        // 接收方法  接收到的是一个socket对象
        Socket accept = ss.accept();
        //socket 的输入流中
        InputStream is = accept.getInputStream();
        //读取数据
        byte[] bytes = new byte[1024];
        int len;
        while ((len=is.read(bytes))!=-1){
            System.out.println(new String(bytes,0,len));
        }
        //关闭流
        is.close();
        ss.close();


    }
}
